package zust.study.设计模式.结构型模式.适配器模式;

import zust.study.设计模式.结构型模式.适配器模式.advancedmedia.AdvancedMediaPlayer;
import zust.study.设计模式.结构型模式.适配器模式.advancedmedia.Mp4Player;
import zust.study.设计模式.结构型模式.适配器模式.advancedmedia.VlcPlayer;

/**
 * @author senselyan
 * @date 2018/6/1 11:02
 */
public class MediaAdapter implements MediaPlayer{

    AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String audioType) {
        if (audioType.equalsIgnoreCase("vlc")) {
            advancedMediaPlayer = new VlcPlayer();
        } else if(audioType.equalsIgnoreCase("mp4")) {
            advancedMediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if (audioType.equalsIgnoreCase("vlc")) {
            advancedMediaPlayer.playerVlc(fileName);
        } else if (audioType.equalsIgnoreCase("mp4")) {
            advancedMediaPlayer.playerMp4(fileName);
        }
    }
}
